<template>
  <div class="app-container">
    <ul class="over-menu">
      <template v-for="(item,index) in tableData">
        <li v-if="item.state" class="enable" :class="current === index?'active':''" @click="setCurrent(index)">
          {{ item.title }}
        </li>
        <li v-else class="disable">
          {{ item.title }}
        </li>
      </template>
    </ul>
    <div style="height: 20px"></div>
    <el-row :gutter="20">
      <el-col :span="16">
        <div class="over-box">
          <div class="over-title">数据范围：{{ title }}</div>
          <div class="over-map">
            <over-map :checkedValue="current"></over-map>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="over-box">
          <div class="over-bold">奉化产业经济发展概况</div>
          <ul class="over-ul">
            <li v-for="item in moneyData">
              <div>
                <span>{{item.name}}</span>
                <span>{{item.value}}</span>
                <span>万元</span>
              </div>
              <div>
                同比 {{item.rate}}%
              </div>
            </li>
          </ul>
          <div style="height: 50px"></div>
          <div class="over-bold">区域发展排行一览</div>
          <div style="padding: 10px">
            <el-table height="400px" :data="distributionData" style="width: 100%">
              <el-table-column type="index" label="排名" align="center" width="55" />
              <el-table-column prop="deptName" label="区域"/>
              <el-table-column prop="total" label="企业总数"  />
              <el-table-column prop="keyPoint" label="重点企业" />
              <el-table-column prop="rate" label="所占比例" width="250px" >
                <template #default="scope">
                  <el-progress :percentage="(scope.row.rate * 100).toFixed(2)" />
                </template>
              </el-table-column>
            </el-table>
          </div>

        </div>
      </el-col>
    </el-row>
  </div>
</template>


<script setup>
import {baseData} from '../data/data.js'
import {reactive, ref} from "vue";
import OverMap from "@/views/industryAnalysis/components/overMap.vue";
import money from "../data/money.json"
import distribution from "../data/distribution.json"


const tableData = reactive(baseData)
const current = ref(0)
const title = ref(tableData[0].title)
const setCurrent = (index) => {
  current.value = index
  title.value = tableData[index].title
}

const moneyData = reactive(money)
const distributionData = reactive(distribution)
</script>


<style scoped lang="scss">
.app-container {
  padding: 20px;
}

.over-menu {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  background-color: #ffffff;

  > li {
    width: calc(100% / 8 - 20px);
    line-height: 40px;
    text-align: center;

  }

  .enable {
    cursor: pointer;
    background-color: #f0f0f0;
    color: #2758bb;
    border: 1px solid #2358bb;
  }

  .disable {
    cursor: not-allowed;
    background-color: #f0f0f0;
    color: #bbbbbb;
    border: 1px solid #bbbbbb;
  }

  .active {
    color: #ffffff;
    background-color: #2758bb;
  }
}

.over-box {
  height: calc(100vh - 200px);
  background-color: #ffffff;

  .over-title {
    padding: 20px;
  }
  .over-map{
    height: calc(100% - 80px);
    margin: 0 20px;
    background-color: red;
  }

  .over-bold{
    font-size:18px;
    font-weight: bold;
    padding: 10px 20px;
    margin-bottom: 20px;
    position: relative;
    &::before{
      content: '';
      position: absolute;
      top: 15px;
      left: 0;
      width: 4px;
      height: 20px;
      background-color: #3b77e3;
    }
  }
  .over-ul{
    >li{
      display: flex;
      justify-content: space-between;
      padding: 10px 20px;
      font-size: 14px;
      >div{
        position: relative;
        &:nth-child(1){
          padding-left: 30px;
          >span{
            margin-right: 20px;
          }
          >span:nth-child(2){
            font-weight: bold;
          }

          &:before{
            content: '';
            position: absolute;
            left: 0;
            top: 5px;
            width: 10px;
            height: 10px;
            background-color: #0b63b7;
            border-radius: 50%;
          }
        }
        &:nth-child(2){
          color: #77c865;
          font-weight: bold;
        }
      }

    }
  }
}

</style>
